package com.xyz.study.design_mode.a_iterator;

import com.xyz.study.design_mode.a_iterator.mode.Book;
import com.xyz.study.design_mode.a_iterator.mode.MyIterator;
import com.xyz.study.design_mode.a_iterator.mode.MyList;

/**
 * 适应设计模式：其一 ---- Iterator 迭代器模式
 *
 * @author XYZ
 * @version 1.0.0
 * @since 2020/6/22
 */
public class IteratorMain {

    public static void main(String[] args) {
        Book book1 = new Book("11");
        Book book2 = new Book("22");
        Book book3 = new Book("33");
        Book book4 = new Book("44");
        Book book5 = new Book("55");

        MyList<Book> myList = new MyList<>();
        myList.add(book1);
        myList.add(book2);
        myList.add(book3);
        myList.add(book4);
        myList.add(book5);

        MyIterator<Book> myIterator = myList.iterator();
        while (myIterator.hasNext()){
            Book book = myIterator.next();
            System.out.println(book.getName());
        }
    }
}
